﻿create procedure dbo.GetPreferredUserOrders
(
		@UserID int
	)

AS


SELECT DISTINCT 
                      dbo.PreferredTakeoutMenu.Name AS PreferredTakeoutMenuName, dbo.PreferredTakeoutMenu.Id AS PreferredTakeoutMenuID, 
                      dbo.vwActiveTakeoutProviders.TakeoutProviderID
FROM         dbo.PreferredTakeoutMenu INNER JOIN
                      dbo.PreferredTakeoutMenuItems ON dbo.PreferredTakeoutMenu.Id = dbo.PreferredTakeoutMenuItems.PreferredTakeoutMenuId INNER JOIN
                      dbo.MenuItems ON dbo.PreferredTakeoutMenuItems.MenuItemID = dbo.MenuItems.Id INNER JOIN
                      dbo.vwActiveTakeoutProviders ON dbo.MenuItems.MenusId = dbo.vwActiveTakeoutProviders.MenuID
WHERE     (dbo.PreferredTakeoutMenu.UserID = @UserID)


